//
//  ViewController.swift
//  CollectionViewDemo
//
//  Created by Met on 2022/6/1.
//

import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    
        self.view.backgroundColor = UIColor.white
    
  
        func addBtn( title:String, index: Int ) {
            let btn = Button.str(title).color("#FFF").bg("random")
            let wh: CGFloat = 80.0
            let x = (UIScreen.main.bounds.width-wh)/2.0
            let y = CGFloat(index)*(30.0+wh)+100.0
            btn.frame = .init(x: x, y: y, width: wh, height: wh)
            btn.tag = index
            btn.addTarget(self, action: #selector(handleBtn(btn:)), for: .touchUpInside)

            self.view.addSubview(btn)
        }
        
        
        addBtn(title: "微信Cell", index: 0)
        addBtn(title: "B站Cell", index: 1)
        addBtn(title: "抖音Cell", index: 2)
    }
    
    @objc func handleBtn(btn: UIButton) {
        let listVC = VideoListVC()
        listVC.type = ListType.init(rawValue: btn.tag) ?? .wechat
        self.present(listVC, animated: true, completion: nil)
    }
}
